<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>小米商城后台管理页面</title>
    <meta name="description" content="小米商城后台管理页面">
    <meta name="keywords" content="小米商城后台管理页面">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../js/elementui/index.css">
    <link rel="stylesheet" href="../js/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/backendcss/style.css">
    <style type="text/css">
    .el-main{
        position: absolute;
        top: 70px;
        bottom: 0px;
        left: 200px;
        right: 10px;
        padding: 0;
    }
    </style>
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div id="app">
        <el-container>
            <el-header  class="main-header" style="height:70px;">
                <nav class="navbar navbar-static-top" :class=''>
                    <!-- Logo -->
                    <a href="/index.jsp" class="logo" style="text-align:center">
                        <span class="logo-lg"><img src="../images/milogo.png" style="width: 50px;height: 50px;"></span>
                    </a>
                    <div id="systemtitle">小米商城后台管理系统</div>
                    <div class="right-menu">
                        <span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>
                        <el-dropdown class="avatar-container right-menu-item" trigger="click">
                            <div class="avatar-wrapper">
                                <img src="../images/adminuserlogo.jpg" class="user-avatar">
                                <span class="powerusername">好吃的狼狼</span>
                            </div>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item divided>
                                    <span style="display:block;" v-on:click="updateformshow()">修改密码</span>
                                </el-dropdown-item>
                                <el-dropdown-item divided>
                                        <span style="display:block;" v-on:click="userlogout()">退出</span>
                                    </el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </nav>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <el-menu>
                        <el-submenu v-for="menu in menuList" :index="menu.path">
                            <template slot="title">
                                <i class="fa" :class="menu.icon"></i>
                                {{menu.title}}
                            </template>
                            <template v-for="child in menu.children">
                                <el-menu-item :index="child.path">
                                    <a :href="child.linkUrl" target="right">{{child.title}}</a>
                                </el-menu-item>
                            </template>
                        </el-submenu>
                    </el-menu>
                </el-aside>
                <el-container>

                    <iframe name="right" class="el-main" src="goodtype.html" style="height: calc(100vh - 70px)" frameborder="0"></iframe>
                </el-container>
            </el-container>
        </el-container>

    </div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue/vue.js"></script>
<script src="../js/vue/axios-0.18.0.js"></script>
<script src="../js/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery-3.4.1.min.js"></script>
<script>
    new Vue({
        el: '#app',
        dialogFormVisible4Edit: false,
        data:{
            // 加载左侧菜单内容
            menuList:[
                {
                    "path": "1",
                    "title": "商品管理",
                    "icon":"fa-cart-plus",
                    "children": [{
                        "path": "/1-1",
                        "title": "商品类别",
                        "linkUrl":"goodtype.html",
                        "children":[]
                    },{
                        "path": "/1-2",
                        "title": "商品信息",
                        "linkUrl":"gooditem.html",
                        "children":[]
                    },
                        {
                            "path": "/1-3",
                            "title": "商品图片",
                            "linkUrl":"goodimage.html",
                            "children":[]
                        }


                    ]
                },
                {
                    "path": "2",
                    "title": "用户管理",
                    "icon":"fa-user-circle",
                    "children": [
                        {
                            "path": "/2-1",
                            "title": "用户信息",
                            "linkUrl":"consumer.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "3",
                    "title": "订单管理",
                    "icon":"fa-bars",
                    "children": [
                        {
                            "path": "/3-1",
                            "title": "订单信息",
                            "linkUrl":"orderlist.html",
                            "children":[]
                        }
                    ]
                },
                {
                    "path": "4",
                    "title": "系统管理",
                    "icon": "fa-cog",
                    "children": [
                        {
                            "path": "/4-1",
                            "title": "管理员密码修改",
                            "linkUrl": "adminpassword.html",
                            "children": []
                        }
                    ]
                }
            ]
        },
        created(){
            this.checkloginstatus();
        },
        methods:{
            // 检查用户登录状态，未登录跳转到登录页面
            checkloginstatus(){
                axios.post('/backendlogin/checkLogin.do').then(res=>{
                    console.log(res);
                    if(res.data.errorCode==="100"){
                         $(".powerusername").text("admin");
                    }
                    else{
                        window.location.href="../backendlogin.jsp";
                    }
                })
            },
            // 退出登录
            userlogout(){
                axios.post('/backendlogin/logout.do').then(res=>{
                        window.location.href="../index.jsp";
                })
            },
            updateformshow(){
                this.dialogFormVisible4Edit=true;
            }
        }
    });
    $(function() {
            var wd = 200;
            $(".el-main").css('width', $('body').width() - wd + 'px');
    });
</script>
</html>
